<?php
include 'codeBack.config.php';
include "connectMysql.php";
include "empty.php";
include 'header.php';
$user_id = $_POST['user_id'];
$token = $_POST['token'];
$page = $_POST["page"];
$count = $_POST["count"];
if(!$user_id || !$token || !$page || !$count){
	exit();
}
$start = ($page-1) * $count;
$ac_user_sql = "SELECT * FROM ac_user WHERE user_id='$user_id' AND token='$token'";
$ac_user_result = $mysqli->query($ac_user_sql);
$ac_user_row = mysqli_fetch_object($ac_user_result);

if($ac_user_row->user_id == $user_id && $ac_user_row->token == $token){
	$ac_user_info_sql = "SELECT * from ac_user_info WHERE user_id='$user_id'  order by id desc LIMIT $start,$count";
	$ac_user_info_result = $mysqli->query($ac_user_info_sql);
	while ($ac_user_info_row=mysqli_fetch_object($ac_user_info_result)) {
		$array[] = $ac_user_info_row;
	}
	if(count($array)>0){
		// 说明有数据
		$data = [
			"code"=>$CodeBack["SHOWINFO_SUCCESS_CODE"],
			"user_id"=>$user_id,
			"user_img"=>$ac_user_row->user_img,
			"data"=>$array,
			"message"=>"查询成功",
		];
		echo json_encode($data);
	}else {
		// 没有数据存在
		$data = [
			"code"=>$CodeBack["SHOWINFO_FAILED_CODE"],
			"user_id"=>$user_id,
			"user_img"=>$ac_user_row->user_img,
			"data"=>$array,
			"message"=>"暂无数据",
		];
		echo json_encode($data);
	}
}



